﻿Imports System.Data.SqlClient

Public Class DangNhapDAO

    Shared Function DangNhap(taiKhoang As String, matKhau As String) As String
        Dim cn As SqlConnection = CKetNoi.Connect
        cn.Open()
        Dim cmd As New SqlCommand
        cmd.CommandText = "usp_DangNhap"
        cmd.CommandType = CommandType.StoredProcedure
        cmd.Connection = cn

        Dim para As SqlParameter
        para = New SqlParameter("@TaiKhoan", SqlDbType.NChar, 20)
        para.Direction = ParameterDirection.Input
        para.Value = taiKhoang
        cmd.Parameters.Add(para)

        para = New SqlParameter("@MatKhau", SqlDbType.NChar, 50)
        para.Direction = ParameterDirection.Input
        para.Value = matKhau
        cmd.Parameters.Add(para)

        para = New SqlParameter("@MaNguoiDung", SqlDbType.VarChar, 7)
        para.Direction = ParameterDirection.Output
        cmd.Parameters.Add(para)

        cmd.ExecuteNonQuery()
        Dim kq As String = cmd.Parameters("@MaNguoiDung").Value.ToString()
        cn.Close()
        Return kq
    End Function

End Class
